<script>
var MeetingReviewHeader = {
    data: {
        changePasswordDialogVisible: false,
        passwordInfo: {
            password: '',
            passwordConfirm: ''
        },
    },
    methods: {
        handleHeaderDropdownItemClick(event) {
            var key = event.key
            if (key == 'change-password') {
                this.changePasswordDialogVisible = true
            } else if (key == 'logout') {
                location = '/logout'
            }
        },
        handleChangePasswordOk() {
            let {password, passwordConfirm} = this.passwordInfo
            if (!password) return error("请填写密码")
            if (password.length < 8 || password.length > 16) return error("密码长度应为8-16位")
            if (!passwordConfirm) return error("请确认密码")
            if (password != passwordConfirm) return error("两次填写密码不一致")
            let encryptedText = encrypt.encrypt(password)
            loading('正在处理', 0)
            axios.post("/api/auth/change-password", {
                password: encryptedText
            }).then(res => {
                dismiss()
                this.changePasswordDialogVisible = false
                if (res.data.ok) {
                    success("密码修改成功")
                } else {
                    error(res.data.message)
                }
            })
        }
    }
}
</script>